package com.zhan.easyexcelorder.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.zhan.jpa.model.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "sys_role")
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "entityCache")
@Getter
@Setter
public class SysRole extends BaseEntity implements java.io.Serializable {
    private static final long serialVersionUID = 7399775585017193612L;

    @ApiModelProperty("角色名称")
    private String roleName;
    @ApiModelProperty("角色编码")
    private String roleCode;
    @ApiModelProperty("角色描述")
    private String roleDescription;
    @ApiModelProperty("菜单列表")
    private String menuList;

    @JSONField(serialize = false)
    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
    private List<SysUser> sysUsers;

    @JSONField(serialize = false)
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "id")
    @OrderBy("sortCount asc")
    private List<SysMenu> sysMenus;

}
